package com.pl.lucence.chinese;

import com.pl.lucence.Path;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/lucene")
public class LuceneController {

    @GetMapping("/test")
    public String test(Model model) {
        // 索引所在的目录
        String indexDir = Path.FILE_PATH_CHS;
        // 要查询的字符
//        String q = "南京文明";
        String q = "南京文化";
        try {
            List<String> list = ChineseSearch.search(indexDir, q);
            model.addAttribute("list", list);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "result";
    }
}
